package bishi;

import java.util.*;

/**
 * @Author liuhaoqi
 * @Date 2020/9/26 14:32
 * @Version 1.0
 */
public class Pufa01 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] arr = {1, 1, 1
                , 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4,};
        int n = 1;
        int[] ints = pufafun01(arr, n);
//        for (int i = 0; i < ints.length; i++) {
//            System.out.println(ints[i]);
//        }
    }

    public static int[] pufafun01(int[] arr, int n) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < arr.length; i++) {
            map.put(arr[i], map.getOrDefault(arr[i], 0) + 1);
        }
        ArrayList<String> list = new ArrayList<>();
        TreeSet<String> set = new TreeSet<>(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                int a = Integer.parseInt(o1.split("#")[1]);
                int b = Integer.parseInt(o2.split("#")[1]);
                return b-a;
            }
        });
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            list.add(entry.getKey() + "#" + entry.getValue());
            set.add(entry.getKey() + "#" + entry.getValue());
        }

        int[] ints = new int[n];
        for (int i = 0; i < n; i++) {
//            ints[i] = Integer.parseInt(list.get(i).split("#")[0]);

        }
        int temp = 0;
        Iterator<String> iterator = set.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next().split("#")[0]);
            temp++;
            if (temp == n) {
                break;
            }
        }
        return ints;
    }
}
